-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.x super #507
3.x super #507
Conversation
consistent strings
consistent strings
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rafaelfranca (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
use default cache size for new caches
lib/sprockets/resolve.rb
Outdated
@@ -153,6 +153,12 @@ def parse_accept_options(mime_type, types) | |||
end | |||
|
|||
def path_matches(load_path, logical_name, logical_basename) | |||
@@gorilla_djungle_banana_cache ||= {} | |||
app_root = Sprockets.check_modified_root | |||
is_in_app = load_path[0...app_root.size] == app_root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to stringify app_root
here. That config option can be nil
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, that method call is used in several places. Might make sense to always return a string from it instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_in_app = load_path.start_with?(app_root.to_s)
@@ -84,6 +84,39 @@ def detect_digest_class(bytes) | |||
} | |||
private_constant :ADD_VALUE_TO_DIGEST | |||
|
|||
def a_v_t_d(c, v, d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't significantly faster, only 10% on ruby 2.4 and even slower on older versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, interesting, it makes the digest completely disappear from my callgraph,
what os, cpu are did you try on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, if 10% is not significant ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10% improvement looks nice, but if this call takes for instance only 5% of the entire compilation process, than it's only a microoptimization without any significant effect.
I was wondering how fast this digest optimization is, so I tested it on our pipeline (big project) and here're my numbers (spent time in this method, same hw)
ruby 2.4.2 windows 29,4% faster
ruby 2.4.2 linux 17,1% faster
ruby 2.1.9 windows 8,6% slower
ruby 2.1.9 linux 17.6% faster
jruby 9.1.13.0 windows 10,3% slower
jruby 9.1.13.0 linux 11,1% slower
I didn't have time to dig deeper. In my opinion your implementation should be faster, but optimizations are sometimes tricky :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the numbers, terrific :)
With the compilation time going down 10 times, the digest became very well visible in the call graph, therefore i looked at it, because that small improvement became more significant with overall times going down that much.
ruby 2.1.* is obsolete since spring 2017
jruby only supports rails 4, which is, except for severe security issues, out of support too
And if a case is slower on jruby, and if this project really wants to support jruby, this may be a good case for opening a 'performance: case' ticket over at jruby. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I optimized this using refinements, it's even faster than what we ended up with in MRI. But it made it way slower on jruby.
If you're going to do microbenchmarks, please use benchmark-ips as in
- Prefer Hash#[] over Set#.include? for speed #312
- validate_processor_result! takes up a lot of time #383
- Speed up digests with refinements #417
Last time we looked at this the hash method was faster than the case method. A big improvement was added when we started using compare with identity https://github.com/rails/sprockets/pull/439/files.
# Conflicts: # lib/sprockets/cache.rb # lib/sprockets/uri_utils.rb
i close this, i created a opal-webpack-loader instead |
for #504
also see #503
you have to set:
Sprockets.check_modified_root = Rails.root.join('app')
with cache adjustment:
gorilla patches